package hot.hash;

import java.util.HashSet;
import java.util.Set;

public class A349 {
}
class Solution {
    public int[] intersection(int[] nums1, int[] nums2) {
        Set<Integer> set=new HashSet<>();
        for (int i : nums1) {
            set.add(i);
        }
        Set<Integer> res=new HashSet<>();
        for (int i : nums2) {
            if(set.contains(i))res.add(nums2[i]);
        }
        int[] result=new int[res.size()];
        int index=0;
        for (Integer r: res) {
            result[index++]=r;
        }
        return result;
    }
}